package com.fh.service.penalty_interest_reduction;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fh.mapper.loan.CallLoanBorrowInfoMapper;
import com.fh.mapper.loan.CallLoanInfoMapper;
import com.fh.mapper.loan.ReducteOverdueInfoMapper;
import com.fh.model.Page;
import com.fh.model.loan.CallLoanBorrowInfo;
import com.fh.model.loan.CallLoanInfo;
import com.fh.model.loan.CallLoanSysLog;
import com.fh.model.loan.ReducteOverdueInfo;
import com.fh.model.system.User;
import com.fh.service.cuijimanage.CuijimanageServiceImpl;
import com.fh.util.Const;
import com.fh.util.DateUtil;
import com.fh.util.HttpUtils;
import com.fh.util.JsonUtil;
import com.fh.util.PageData;
import com.fh.util.R;
import com.ybd.common.component.redis.StringRedisUtil;
/**
 * 
 * @author yc、
 *
 */
@Service
public class ReducteOverdueInfoServiceImpl implements IReducteOverdueInfoService{
    
    private Logger logger = LoggerFactory.getLogger(ReducteOverdueInfoServiceImpl.class);
    
	@Autowired
	private ReducteOverdueInfoMapper mapper;
	@Autowired
	private IPenaltyInterestReductionService PIRService;
	@Autowired
	private CallLoanInfoMapper callLoanInfoMapper;
	@Autowired
	private CuijimanageServiceImpl cuijimanageServiceImpl;
	@Autowired
	private CallLoanBorrowInfoMapper callLoanBorrowInfoMapper;
	@Autowired
	private ReducteOverdueInfoMapper reducteOverdueInfoMapper;
	@Autowired
    private StringRedisUtil stringRedisUtil;
	//插入优惠券
    @Value("${url.activityURL}")
    private String activityURL;
    //插入退回券
    @Value("${url.adminByPhp}")
    private String adminByPhp;
	/**
	 * 罚息减免申请
	 * 
	 */
	@Transactional(readOnly=false,propagation=Propagation.REQUIRED)
	public int insert(ReducteOverdueInfo info) {
		//通过催收编号查询需要info表中的信息
		CallLoanInfo callLoanInfo = PIRService.faxijianmianApplyById(info.getCallLoanNid());
		//剩余可申请的罚息减免金额
		BigDecimal receiveMoney = this.getReceiveMoney(callLoanInfo);
		if (info.getReduOverdueFee()== null || info.getReduOverdueFee().compareTo(receiveMoney) > 0 || info.getReduOverdueFee().compareTo(new BigDecimal("0")) < 0)
			throw new RuntimeException("请输入正确的罚息金额!");
		if (info.getReduDay() == null || StringUtils.isBlank(info.getReduInfo()))
			throw new RuntimeException("有效期或减免说明不能为空!");
		if (info.getReduInfo().length() > 200)
			throw new RuntimeException("减免说明字数不能超过200!");
			//封装我需要的字段
			ReducteOverdueInfo overdueInfo = new ReducteOverdueInfo();
			int count = mapper.queryCountByCallLoanNid(info.getCallLoanNid());//通过催收编号查询
			overdueInfo.setCallLoanNid(info.getCallLoanNid());
			overdueInfo.setReduApplyId(info.getCallLoanNid() + "-" + (count + 1));
			overdueInfo.setCreateTime(new Date());
			overdueInfo.setUpdateTime(new Date());
			overdueInfo.setReduDay(info.getReduDay());
			overdueInfo.setReduInfo(info.getReduInfo());
			overdueInfo.setReduOverdueFee(info.getReduOverdueFee());
			User user = getUser();
			overdueInfo.setReduUser(user.getUSER_ID());//申请人编号
			overdueInfo.setStatus(0);
			overdueInfo.setReduStatus(0);//设置罚息减免状态
			overdueInfo.setReturnStatus(-1);//设置罚息退回状态
			overdueInfo.setType(1);//罚息减免类型
			return mapper.insert(overdueInfo);
	}
	/**
	 * 罚息退回申请
	 * 
	 */
	@Transactional(readOnly=false,propagation=Propagation.REQUIRED)
	public int insert2(ReducteOverdueInfo info) {
		//通过催收编号查询需要info表中的信息
		CallLoanInfo callLoanInfo = PIRService.faxijianmianApplyById(info.getCallLoanNid());
		//剩余可退回的罚息减免金额
		BigDecimal returnMoney = this.getReturnMoney(callLoanInfo);
		if (info.getReduOverdueFee()== null || info.getReduOverdueFee().compareTo(returnMoney) > 0 || info.getReduOverdueFee().compareTo(new BigDecimal("0")) < 0)
			throw new RuntimeException("请输入正确的罚息金额!");
		if (info.getReduInfo().length() > 250)
			throw new RuntimeException("退回说明字数不能超过250!");
		//封装我需要的字段
		ReducteOverdueInfo overdueInfo = new ReducteOverdueInfo();
		int count = mapper.queryCountByCallLoanNid(info.getCallLoanNid());//通过催收编号查询
		overdueInfo.setCallLoanNid(info.getCallLoanNid());
		overdueInfo.setReduApplyId(info.getCallLoanNid() + "-" + (count + 1));
		overdueInfo.setCreateTime(new Date());
		overdueInfo.setUpdateTime(new Date());
		overdueInfo.setReduInfo(info.getReduInfo());
		overdueInfo.setReduOverdueFee(info.getReduOverdueFee());
		User user = getUser();
		overdueInfo.setReduUser(user.getUSER_ID());//申请人编号
		overdueInfo.setStatus(0);
		overdueInfo.setReduStatus(-1);//设置罚息减免状态
		overdueInfo.setReturnStatus(0);//设置罚息退回状态
		overdueInfo.setType(2);//罚息退回类型
		return mapper.insert(overdueInfo);
	}
	/**
	 * 获取可申请的罚息减免金额
	 * @return
	 */
	public BigDecimal getReceiveMoney(CallLoanInfo callLoanInfo){
		BigDecimal receiveMoney = new BigDecimal("0.00");
		Map<String,Object> map = new HashMap<>();
		//查询未还罚息
		map.put("repaymentId", callLoanInfo.getRepaymentId());
		CallLoanBorrowInfo selectLoanBorrowInfo = callLoanBorrowInfoMapper.selectLoanBorrowInfo(map);
		if (selectLoanBorrowInfo == null) {
			return receiveMoney;
		}
		//查询未使用的罚息减免
		Map<String,Object> mao = new HashMap<>();
        mao.put("callLoanNid", callLoanInfo.getCallLoanNid());//设置催收编号
        Map<String, Object> reduInfoToanjianDesc = reducteOverdueInfoMapper.reduInfoToanjianDesc(mao);
        if (reduInfoToanjianDesc != null && reduInfoToanjianDesc.get("weishiyong") != null) {
        	//剩余的可申请的罚息减免金额
        	receiveMoney = selectLoanBorrowInfo.getRemainOverdueFee().subtract((BigDecimal)reduInfoToanjianDesc.get("weishiyong"));
		}else{
			receiveMoney = selectLoanBorrowInfo.getRemainOverdueFee();
		}
		return receiveMoney;
	}
	/**
	 * 获取可申请的罚息退回金额
	 * @return
	 */
	public BigDecimal getReturnMoney(CallLoanInfo callLoanInfo){
		BigDecimal returnMoney = new BigDecimal("0.00");
		//查询已还罚息金额
		CallLoanInfo info = callLoanInfoMapper.faxijianmianApplyById(callLoanInfo.getCallLoanNid());
		BigDecimal receveFee = info.getReceveFee();//已还罚息金额
		if (receveFee == null) {
			receveFee = new BigDecimal("0.00");
		}
		BigDecimal penaltyInterestReturn = callLoanInfo.getPenaltyInterestReturn();
		if (penaltyInterestReturn == null) {
			penaltyInterestReturn = new BigDecimal("0.00");
		}
		//可申请的罚息退回金额 = 已还罚息金额 - 已退回的罚息金额 - 已审核的退回金额
		Map<String,Object> mao = new HashMap<>();
        mao.put("callLoanNid", callLoanInfo.getCallLoanNid());//设置催收编号
        Map<String, Object> reduInfoToanjianDesc = reducteOverdueInfoMapper.reduInfoToanjianDesc(mao);
        if (reduInfoToanjianDesc != null && reduInfoToanjianDesc.get("faxituihui") != null) {
        	//剩余的可申请的罚息退回金额
        	returnMoney = receveFee.subtract(penaltyInterestReturn).subtract((BigDecimal)reduInfoToanjianDesc.get("faxituihui"));
		}else{
			returnMoney = receveFee.subtract(penaltyInterestReturn);
		}
		return returnMoney;
	}
	
	
	/**
	 * 获取当前登录用户
	 * 
	 * @return
	 */
	public User getUser(){
		Subject currentUser = SecurityUtils.getSubject();  
		Session session = currentUser.getSession();
		return (User)session.getAttribute(Const.SESSION_USER);
	}
	/**
	 * 罚息减免待审核列表
	 * 
	 */
	public List<PageData> findlistPage(Page page) {
		R.setPageHelper(page.getPd());
		List<PageData> list = mapper.findWaitPage(page);
		R.setPage(page, list);
		return list;
	}

	/**
	 * 单笔审核页面
	 * 
	 */
	@Transactional(readOnly=true)
	public PageData queryByReduApplyId(String reduApplyId) {
		PageData pd = mapper.queryByReduApplyId(reduApplyId);
		return pd;
	}

	/**
	 * 单笔审核逻辑
	 * 
	 */
	@Transactional(readOnly=false,propagation=Propagation.REQUIRED)
	public void  auditOne(ReducteOverdueInfo info) throws Exception {
		this.audit(info);
	}
	
	private synchronized void audit(ReducteOverdueInfo info) throws Exception {
		ReducteOverdueInfo newInfo = mapper.queryByReduApplyIdAudit(info.getReduApplyId());
		//创建催计消息对象
		CallLoanSysLog log = new CallLoanSysLog();
		if (StringUtils.isBlank(info.getVerifyRemark())) 
			throw new RuntimeException("审核说明不能为空!");
		if (info.getVerifyRemark().length() > 200) 
			throw new RuntimeException("审核说明字数不能超过200!");
		if (info.getStatus() == 1 && newInfo.getStatus() != 0)
			throw new RuntimeException("退免申请编号为" + info.getReduApplyId() + ",审核状态不为待审核!");
		//通过催收编号查询需要info表中的信息
		CallLoanInfo callLoanInfo = PIRService.faxijianmianApplyById(newInfo.getCallLoanNid());
		//剩余可申请的罚息减免金额
		BigDecimal receiveMoney = this.getReceiveMoney(callLoanInfo);
		//剩余可申请的罚息退回金额
		BigDecimal returnMoney = this.getReturnMoney(callLoanInfo);
		if (info.getStatus() == 1  &&  newInfo.getType() == 1 && newInfo.getReduOverdueFee().compareTo(receiveMoney) > 0)
			throw new RuntimeException("退免申请编号为" + info.getReduApplyId() + ",已超出可减免金额!");//判断申请减免金额是否大于罚息金额(是否有剩余罚息金额)就抛出异常
		if (info.getStatus() == 1  &&  newInfo.getType() == 2 && newInfo.getReduOverdueFee().compareTo(returnMoney) > 0)
			throw new RuntimeException("退免申请编号为" + info.getReduApplyId() + ",已超出可退回金额!");
		//判断审核状态为审核通过(1)还是审核拒绝(2)
		if (newInfo.getStatus() == 0////判断审核之前的状态是否为待审核"0"
				) {
			newInfo.setVerifyRemark(info.getVerifyRemark());
			newInfo.setAuditTime(new Date());
			//审核人
			User user = getUser();
			newInfo.setAuditUser(user.getUSER_ID());
			//催计消息公共部分
			log.setCallUser(newInfo.getReduUser());//催计消息添加申请人
			log.setIsDelete(0);//
			log.setStatus(0);
			log.setCreateTime(new Date());
			log.setUpdateTime(new Date());
			if (info.getStatus() == 1) {//审核通过
				//修改罚息申请信息
				newInfo.setReduStatus(0);
				newInfo.setStatus(1);
				//审核通过催计消息
				log.setTitle("退免审核通过消息通知");//标题
				log.setContent("退免申请编号" + info.getReduApplyId() +"，已经审核通过，请尽快处理");//内容
				if (newInfo.getType() == 1) {
					//罚息减免优惠券
					//调用插入罚息减免券接口
					this.insertActivity(newInfo, callLoanInfo, info);
				}
				if (newInfo.getType() == 2) {
					//罚息退回
					this.insertAdminPhp(newInfo, callLoanInfo, newInfo);
				}
			}else{
				//审核拒绝
				newInfo.setStatus(2);
				//审核拒绝催计消息
				log.setTitle("退免审核拒绝消息通知");//标题
				log.setContent("退免申请编号" + info.getReduApplyId() +"，已经审核拒绝，请尽快处理");//内容
			}
			//更新罚息申请表
			mapper.updateByReduApplyId(newInfo);
			//审核罚息减免催计消息
			cuijimanageServiceImpl.insertCuijiMsg(log);

		}else{
			throw new RuntimeException("审核失败,审核状态不为0!");
		}
	}
	
	
	/**
	 * 调用活动系统插入罚息减免券的接口
	 * @throws Exception
	 *
	 */
	public  void insertActivity(ReducteOverdueInfo newInfo,CallLoanInfo callLoanInfo,ReducteOverdueInfo info) throws Exception{
		/**
		 * 1. 取redis是否存在数据,如果存在了不在插入数据.
		 * 2. 如果不存在的,redis插入值,在插入数据接口
		 */
		String key = info.getReduApplyId() + info.getVerifyRemark();
		String value = JSON.toJSONString(info);
		if (stringRedisUtil.get(key) == null) {
			stringRedisUtil.put(key, value, 1, TimeUnit.SECONDS);
			//如果审核通过减免申请的减免状态就变为未使用
			//调用接口,将审核通过的减免状态为未使用的减免申请插入到优惠券系统里面
			Map<String, String> parameters = new HashMap<String, String>();
			parameters.put("status", "1");//减免状态'未使用'
			parameters.put("createTime", DateUtil.getIntTime(newInfo.getAuditTime()) + "");//创建时间
			parameters.put("startTime", DateUtil.getIntTime(newInfo.getAuditTime()) + "");//起始时间
			parameters.put("endTime", DateUtil.getIntTime(newInfo.getReduDay()) + "");//结束时间
			parameters.put("discountValue", newInfo.getReduOverdueFee() + "");//罚息减免金额
			parameters.put("borrowNid", callLoanInfo.getBorrowNid());//借款编号
			parameters.put("minPrice", newInfo.getReduOverdueFee() + "");//最低使用额度
			parameters.put("nid", info.getReduApplyId());//罚息减免编号对应着优惠券系统中的订单编号
			parameters.put("mamiUserId", callLoanInfo.getUserId() + "");//用户id
			parameters.put("period", callLoanInfo.getPeriod() + "");//期数
			parameters.put("sourceFrom", "8");//罚息减免优惠券
			logger.info("调用创建罚息减免券接口参数:ReducteOverdueInfoServiceImpl insertActivity:{}",parameters);
			String result = HttpUtils.sendPost(activityURL + "info/discount/insertCoupon", parameters);//判断是否插入成功了!
			logger.info("调用创建罚息减免券接口:ReducteOverdueInfoServiceImpl insertActivity:{}",result);
			if (StringUtils.isBlank(result)) {
				//调用接口失败
				throw new RuntimeException("调用接口失败!");
			}
			logger.info("=========not redis exit==================" + stringRedisUtil.get(key));
		}else{
			logger.error(String.format("调用创建罚息减免券接口重复 ReducteOverdueInfoServiceImpl auditOne:%s;Redis中存在的数据:%s",info.getReduApplyId(),stringRedisUtil.get(key)));
		}
	}
	/**
	 * 调用清结算插入罚息退回券的接口
	 * @throws Exception
	 *
	 */
	public  void insertAdminPhp(ReducteOverdueInfo newInfo,CallLoanInfo callLoanInfo,ReducteOverdueInfo info) throws Exception{
		/**
		 * 1. 取redis是否存在数据,如果存在了不在插入数据.
		 * 2. 如果不存在的,redis插入值,在插入数据接口
		 */
		String key = info.getReduApplyId() + info.getVerifyRemark();
		String value = JSON.toJSONString(info);
		if (stringRedisUtil.get(key) == null) {
			//stringRedisUtil.put(key, value, 1, TimeUnit.MINUTES);
			//如果审核通过退回申请的变为审核中
			//===================================================================================
			 HttpPost httpPost = new HttpPost(adminByPhp + "ServiceApi/ReceivePenaltyRefundRequest");
			 CloseableHttpClient client = HttpClients.createDefault();
			 String respContent = null;
			 
			 JSONObject jsonParam = new JSONObject();  
			 jsonParam.put("order_source", callLoanInfo.getProductSource());//渠道来源
			 jsonParam.put("order_no", info.getReduApplyId());//订单号
			 jsonParam.put("borrow_nid", callLoanInfo.getBorrowNid());//标的号
			 jsonParam.put("period", String.valueOf(callLoanInfo.getPeriod()));//期数
			 jsonParam.put("account_id", callLoanInfo.getAccountId());//借款人账户id
			 jsonParam.put("real_name", callLoanInfo.getRealName());//借款人真实姓名
			 jsonParam.put("receve_overdue_fee_total", String.valueOf(callLoanInfo.getReceveFee()));//当时已收罚息
			 jsonParam.put("surrenderback_overdue_fee_total", String.valueOf(newInfo.getReduOverdueFee()));//罚息退回申请金额
			 jsonParam.put("confirm_time", DateUtil.getTime());//申请时间
			 jsonParam.put("reason", newInfo.getReduInfo());//申请原因
			 logger.info("调用创建罚息退回券接口参数:ReducteOverdueInfoServiceImpl insertAdminPhp:{}",jsonParam);
			 StringEntity entity = new StringEntity(jsonParam.toString(),"utf-8");//解决中文乱码问题    
			 entity.setContentEncoding("UTF-8");    
			 entity.setContentType("application/json");
			 httpPost.setEntity(entity);
			 System.out.println();
			 try {
			 	HttpResponse resp = client.execute(httpPost);
			 	if(resp.getStatusLine().getStatusCode() == 200) {
			 		HttpEntity he = resp.getEntity();
			 		respContent = EntityUtils.toString(he,"UTF-8");
			 	}
			} catch (Exception e) {
				logger.error("插入罚息退回券异常",e);
			}
			Map map = new HashMap();
			if (StringUtils.isBlank(respContent)) {
				throw new RuntimeException("调用罚息退回接口失败!");
			}
			map= JsonUtil.jsonToMap(respContent);
			logger.info("调用创建罚息退回券接口:ReducteOverdueInfoServiceImpl insertActivity:{}",respContent);
			if (Integer.parseInt(map.get("code") + "") != 200) {
				//调用接口失败
				throw new RuntimeException(map.get("msg") + "");
			}
			logger.info("=========not redis exit==================" + stringRedisUtil.get(key));
		}else{
			logger.error(String.format("调用创建罚息退回券接口重复 ReducteOverdueInfoServiceImpl auditOne:%s;Redis中存在的数据:%s",info.getReduApplyId(),stringRedisUtil.get(key)));
		}
	}


	/**
	 * 批量审核
	 * 
	 */
	@Transactional(readOnly=false,propagation=Propagation.REQUIRED)
	public void updateAuditBatchSave(String DATA_IDS, int auditStatus, String verifyRemark) throws Exception {
		if(null != DATA_IDS && !"".equals(DATA_IDS)){
			String ArrayDATA_IDS[] = DATA_IDS.split(",");//获取所有的reduApplyId
			for (String reduApplyId : ArrayDATA_IDS) {
				//查询罚息减免申请表的信息
				ReducteOverdueInfo info = new ReducteOverdueInfo();
				info.setReduApplyId(reduApplyId);
				info.setStatus(auditStatus);
				info.setVerifyRemark(verifyRemark);
				audit(info);
			}
		}
	}
	/**
	 * 审核状态查询
	 * 
	 */
	public List<PageData> reduStatuslistPage(Page page) {
		R.setPageHelper(page.getPd());
		List<PageData> list = mapper.reduStatusPage(page);
		R.setPage(page, list);
		return list;
	}
	/**
	 * 修改罚息减免优惠券的使用状态
	 * 
	 */
	@Transactional(readOnly=false,propagation=Propagation.REQUIRED)
	public void updateReduStatusByReduApplyId(ReducteOverdueInfo info) {
		mapper.updateReduStatusByReduApplyId(info);
	}
	/**
	 * 罚息减免编号查询
	 */
	public ReducteOverdueInfo queryByReduApplyIdAudit(String reduApplyId) {
		return mapper.queryByReduApplyIdAudit(reduApplyId);
	}
	/**
	 * 5分钟执行一次定时任务:改变罚息减免券是否失效
	 */
	@Transactional(readOnly=false,propagation=Propagation.REQUIRED)
	public void updateReduStatusByJob() {
			logger.info("罚息减免5分钟定时job");
		   //干调活动系统保证活动系统的罚息减免券失效
	       Map<String, String> parameters = new HashMap<String, String>();
	       parameters.put("sourceFrom", "8");//罚息减免优惠券
	       HttpUtils.sendPost(activityURL + "info/discount/selectCouponList", parameters);
	       //干调活动系统保证活动系统的罚息减免券失效
	       //查询本地库未使用的且审核通过的罚息减免券
	       List<ReducteOverdueInfo> allList = mapper.queryAllUnUser();
	       allList.stream()
	       		.filter(x->x.getReduDay().compareTo(new Date())<=0)
	       		.forEach( m -> {
    		   //满足有效期到期后循环迭代所有的罚息减免券
	    	   m.setReduStatus(2);//减免状态变成已过期
	    	   m.setUpdateTime(new Date());//设置更新时间
    		   this.updateReduStatusByReduApplyId(m);//更新罚息减免券的状态
	       });
	}
	@Override
	public CallLoanInfo queryByCallLoanNid(String callLoanNid) {
		return callLoanInfoMapper.queryByCallLoanNid(callLoanNid);
	}
	/**
	 * 更新主表罚息减免金额
	 * 
	 */
	@Transactional(readOnly=false,propagation=Propagation.REQUIRED)
	public void updateReduMoney(CallLoanInfo callLoanInfo, BigDecimal reduOverdueFee) {
		if (callLoanInfo != null) {
			CallLoanInfo info = new CallLoanInfo();
			info.setRepaymentId(callLoanInfo.getRepaymentId());//设置还款订单号
			//info.setVersion(callLoanInfo.getVersion());//设置版本号
			info.setUserReduOverdueFee(callLoanInfo.getUserReduOverdueFee().add(reduOverdueFee));//总的罚息减免金额
			callLoanInfoMapper.updateReduMoney(info);
		}
	}
	/**
	 * 修改罚息退回状态
	 */
	@Transactional(readOnly=false,propagation=Propagation.REQUIRED)
	public int updateReturnFeeStatus(String order_no, Integer status) {
		return mapper.updateReturnFeeStatus(order_no,status);
	}
	/**
	 * 修改主表罚息退回金额
	 */
	@Transactional(readOnly=false,propagation=Propagation.REQUIRED)
	public int updateReturnFeeMoney(String reduApplyId) {
		//先查询罚息退回的金额
		ReducteOverdueInfo info = mapper.queryByReduApplyIdAudit(reduApplyId);
		int count = 0;
		if (info != null) {
			CallLoanInfo callLoanInfo = callLoanInfoMapper.faxijianmianApplyById(info.getCallLoanNid());
			callLoanInfo.setPenaltyInterestReturn(callLoanInfo.getPenaltyInterestReturn().add(info.getReduOverdueFee()));
			count = callLoanInfoMapper.updateReturnFeeMoney(callLoanInfo);
		}
		return count;
	}
	
	
}
